const { Router } = require("express");

const Library = require("../model/Library");

// 这行代码创建了一个新的Router实例，用于定义和配置路由的具体行为。
const router = new Router();

/* 增加 */
//http://localhost:8000/routers/library/add
router.post("/add", async (req, res) => {
  const {
    libraryName,
    site,
    detailedAddress,
    longitude,
    settlementInterval,
    proportion,
    operatingBank,
    creditCardNumbers,
    realName,
    IDNumber,
    cellPhoneNumber,
  } = req.body;
  const data = await Library.create({
    libraryName,
    site,
    detailedAddress,
    longitude,
    settlementInterval,
    proportion,
    operatingBank,
    creditCardNumbers,
    realName,
    IDNumber,
    cellPhoneNumber,
  });
  if (data) {
    res.json({
      msg: "添加成功",
      data,
    });
  } else {
    res.json({
      msg: "添加不成功",
    });
  }
});

/*  */

module.exports = router;
